package cn.wolfcode.crm.service.impl;

import cn.wolfcode.crm.domain.PaymentHandling;
import cn.wolfcode.crm.mapper.PaymentHandlingMapper;
import cn.wolfcode.crm.query.ObjectQuery;
import cn.wolfcode.crm.query.PageResult;
import cn.wolfcode.crm.service.IPaymentHandlingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

@Service
public class PaymentHandlingServiceImpl implements IPaymentHandlingService {
    @Autowired
    private PaymentHandlingMapper carMapper;

    public void save(PaymentHandling record) {
        carMapper.insert(record);
    }

    public void delete(Long id) {
            carMapper.deleteByPrimaryKey(id);

    }

    public void update(PaymentHandling record) {
        carMapper.updateByPrimaryKey(record);
    }

    public PaymentHandling get(Long id) {
        return carMapper.selectByPrimaryKey(id);
    }

    public List<PaymentHandling> getAll() {
        return carMapper.selectAll();
    }

    public PageResult<PaymentHandling> query(ObjectQuery qo) {
        int totalCount = carMapper.queryForCount(qo);
        if (totalCount == 0) {
            return new PageResult<PaymentHandling>(totalCount, Collections.<PaymentHandling>emptyList());
        }
        return new PageResult<PaymentHandling>(totalCount, carMapper.queryForList(qo));
    }




}
